home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / srefv12i.zip / accescfg.cmd next >
OS/2 REXX Batch file  |  1997-03-21  |  29KB  |  663 lines

  1. /*  */
  2. accescfg:
  3.  
  4. CHECKIT=0   /* Change this to 0 if you want to enable REMOTE configuration by SUPERUSERS */
  5.  
  6. /* background color */
  7. USECOLOR='2dd52f'
  8.  
  9. /* ---------------- DO NOT MODIFY BELOW THIS LINE  ------------------ */
  10.  
  11. parse arg ddir,tempfile,sel,list,verb,uri,user,basedir,workdir,privset,enmadd,transaction,verbose
  12.  
  13. list=translate(list, ' ', '+'||'090a0d'x)  /* Whitespace, etc. */
  14.  
  15. if verb="" then do
  16.    say " This SRE-Filter add-on is NOT meant to be run from the command line."
  17.    say " It can be invoked by using CONFIGUR.HTM "
  18.    exit
  19. end  /* Do */
  20.  
  21.  
  22.  
  23. who2=extract('CLIENTADDR')
  24. saddr2=extract('SERVERADDR')
  25.  
  26.  
  27.  
  28. select
  29.    when checkit=1 then do
  30.  
  31. /* only if user = serveraddress !!! */
  32.      if who2<>saddr2 then do
  33.  
  34.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  35.         call lineout tempfile, "<html><head><title>SREFILTER ERROR </title>"
  36.         call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  37.  
  38.         call lineout tempfile,' <strong> Action not allowed remotely.</strong> <pre>'
  39.         call lineout tempfile,' </body> </html> '
  40.         call lineout tempfile
  41.         'FILE ERASE TYPE text/html NAME' tempfile
  42.         return 'ACCESCFG: action not allowed remotely. '
  43.      end
  44.    end
  45.    otherwise do
  46.       if wordpos('SUPERUSER',privset)=0 then do
  47.        'RESPONSE HTTP/1.0 401 Unauthorized '     /* Set HTTP response line */
  48.         'header add WWW-Authenticate: Basic Realm=<CONFIGURE>'  /* challenge */
  49.  
  50.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  51.         call lineout tempfile, "<html><head><title>Not authorized </title>"
  52.         call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  53.  
  54.  
  55.         call lineout tempfile,' <strong> You do not have configuration rights.</strong> <pre>'
  56.         if who2=saddr2 then 
  57.                 call lineout tempfile,'<br> <Em> You may want to edit ACCESCFG.CMD </em> '
  58.         call lineout tempfile,' </body> </html> '
  59.         call lineout tempfile
  60.          iia=dosdir(tempfile,'s')
  61.  
  62.         'FILE ERASE TYPE text/html NAME' tempfile
  63.         return '401 'iia' ACCESCFG: not permitted to configure. '
  64.       end
  65.    end
  66. end
  67.  
  68. list=strip(list)
  69. select 
  70.    when upper(list)='TODO=SHOW' | upper(list)='TODO=SHOW_HEADER' then
  71.         signal doshow
  72.    when upper(list)='TODO=SET' then
  73.         signal doset
  74.    otherwise
  75.         signal dochange
  76. end  /* select */
  77.  
  78.  
  79. /* jump here to show values */
  80. doshow:
  81.  
  82.  
  83. accessfile=value(enmadd||'ACCESS_FILE',,'os2environment')
  84.    call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  85.    call lineout tempfile, "<html><head><title>SRE-Filter: SEL-Specific access control </title>"
  86.    call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  87.  
  88.  
  89. aa=fileread(accessfile,'lins',,'E')
  90. foo=do_extends(1)
  91.  
  92. call lineout tempfile, "<h1> SRE-Filter:  SEL-Specific access control  </h1> <p>"
  93. if upper(list)='TODO=SHOW' then
  94.   call lineout tempfile, "<h2> List of "header" comments </h2> <pre> <blockquote>"
  95. else
  96.   call lineout tempfile, "<h3> Brief descripton  </h3> <pre> <blockquote>"
  97.  
  98. /* show "header comments" */
  99. iat=0
  100. do until iat >= lins.0
  101.    iat=iat+1
  102.    if  abbrev(strip(lins.iat),';')  then do
  103.         foo=strip(lins.iat) ;foo=strip(foo,'l',';')
  104.          call lineout tempfile, foo 
  105.    end  /* Do */
  106.    else do
  107.         leave
  108.    end
  109. end /* do -- iat is the first non header comment line  */
  110. call lineout tempfile, '</blockquote></pre> '
  111.  
  112. /* view descriptive header only? */
  113. if upper(list)='TODO=SHOW_HEADER' then do
  114.    call lineout tempfile,' <hr> </body></html>'
  115.    call lineout tempfile
  116.    'file erase  type text/html name  ' tempfile
  117.    return ' done '
  118. end  /* Do */
  119.  
  120.  
  121.  
  122. /* read in usernames, etc */
  123. nusers=0
  124. call lineout tempfile, '<hr> <h2> A List of selector specific access controls </h2> '
  125. call lineout tempfile,' Notes: <ul> '
  126. call lineout tempfile,' <li> SEL-specific access controls are stored in: ' accessfile
  127. call lineout tempfile,' <li> <em>Comments are in italics </em> '
  128. call lineout tempfile,' <li> In <b>Candiate SEL:</b> The <strong>*</strong> character is used as a wildcard (for an arbitrarily long string)'
  129. call lineout tempfile, ' <li> Entries with no <strong>Host Nickname</strong> apply to all requests'
  130. call lineout tempfile,' <li> The <strong>Realm</strong> is sent to the client (when responding to UnAuthorized requests),'
  131. call lineout tempfile,'  and as a shorthand for a <EM>set of resource privileges</EM>'
  132. call lineout tempfile,' <li> The <em>optional</em> <strong> Failure File</strong> is used when responding to <code>Unauthorized</code> requests <br>'
  133. call lineout tempfile,' <li> The <em>optional </em> <b> ADV_OPTS</b> (advanced options</u>) is used to specify additional <em>request selector </em> options '
  134. call lineout tempfile,' <LI>In the <STRONG>Resource Privileges</STRONG> list: <menu> <li><STRONG> *</STRONG> :  <em>any privilege will do</em> '
  135. call lineout tempfile,' <LI><STRONG> NO</STRONG> : No accesss (SUPERUSERS and In-House users only!)  </menu> </ul> '
  136. call lineout tempfile,' <table border=1> <th> Host Nickname </th>'
  137. call lineout tempfile,' <th> Candidate SEL or <br> Realm Name </u> </th>'
  138. call lineout tempfile,'  <th> Resource Privileges List </th>'
  139. call lineout tempfile,'  <th> Permissions list ......</th> <th> Realm </th> <th>Failure File  </th><th> Adv_opts File</th> <tr>'
  140.  
  141. do mm=iat to lins.0
  142.   if lins.mm=' ' then iterate
  143.   stlin=upper(strip(lins.mm))
  144.   if  abbrev(stlin,';')=1 then do
  145.        call lineout tempfile,'<td colspan=5>  <code>     </code> <em>' strip(strip(lins.mm),'l',';') '</em></td> <tr> '
  146.   end
  147.   else do
  148.       if abbrev(stlin,'!REALM')=1  then do
  149.          parse var stlin foo candurl accpriv
  150.          call lineout tempfile,'<td colspan=2>  ......... <em> Realm name: </em> <STRONG> ' candurl '</STRONG> </td>'
  151.          call lineout tempfile,'<td colspan=4>    <STRONG> 'accpriv '</STRONG> </td> <tr>'
  152.       end
  153.       else do
  154.         if pos('// ',lins.mm)>0 then do
  155.            parse var stlin hostname '//' candurl accpriv ',' permissions ',' realm ',' fail_file ',' adv_opts
  156.         end
  157.         else do
  158.            hostname=' .. '
  159.            parse var stlin candurl accpriv ',' permissions ',' realm ',' fail_file ',' adv_opts
  160.         end  /* Do */
  161.        IF ACCPRIV=' ' THEN ACCPRIV='*'
  162.        IF PERMISSIONS=' ' THEN PERMISSIONS='..'
  163.        IF REALM=' ' THEN REALM='..'
  164.        if fail_file=' ' then fail_file='..'
  165.        if adv_opts=' ' then adv_opts='..'
  166.        call lineout tempfile,'<td>     <STRONG>  'hostname '</STRONG> </td>'
  167.        call lineout tempfile,'<td>    <STRONG> ' candurl '</STRONG> </td>'
  168.        call lineout tempfile,'<td>    <STRONG> 'accpriv '</STRONG> </td>'
  169.        call lineout tempfile,'<td>    <STRONG> 'permissions ' </STRONG></td> '
  170.        call lineout tempfile,'<td>    <STRONG> 'realm'  </STRONG></td> '
  171.        call lineout tempfile,'<td>    <STRONG> ' fail_file'  </STRONG> </td> '
  172.        call lineout tempfile,'<td>    <STRONG> ' adv_opts'  </STRONG></td> <tr>'
  173.  
  174.  
  175.     end /* do  urls */
  176.   end           /* non comment line */
  177.  
  178. end /* mm */
  179. call lineout tempfile,' </table>'
  180.  
  181. call lineout tempfile,'<hr><h3> Definitions of the Permissions </h3>'
  182. foo=show_permissions()
  183.  
  184.  
  185.  
  186. call lineout tempfile,' <hr> Thanks for checking </body></html>'
  187.  
  188. call lineout tempfile
  189.  
  190. foo=sref_expire_response(0.05,dosdir(tempfile))
  191. 'file erase  type text/html name  ' tempfile
  192. return ' done '
  193.  
  194.  
  195.  
  196. /* jump here if "set values" chosen */
  197. doset:
  198. accessfile=value(enmadd||'access_FILE',,'os2environment')
  199. aa=fileread(accessfile,'lins',,'E')
  200. foo=do_extends(1)
  201.  
  202. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  203. call lineout tempfile, "<html><head><title>SRE-Filter: modify  SEL-specific access controls </title>"
  204.  call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  205.  
  206.  
  207. /* ignore header stuff */
  208. iat=0
  209. do until iat >= lins.0
  210.    iat=iat+1
  211.    if  abbrev(strip(lins.iat),';') | lins.iat=' ' then iterate
  212.    leave
  213. end /* do -- iat is the first non header comment line  */
  214. call lineout tempfile, "<h1> SRE-Filter: modify <A NAME="top">SEL-specific access controls</A>  </h1> <p>"
  215. call lineout tempfile,' <blockquote> You can modify, remove, or add SEL-specific access controls and realm definitions.'
  216. call lineout tempfile,' <br><em> Questions? <A HREF="#notes">The notes might help.</A> </em> </blockquote> '
  217. call lineout tempfile,' <h2> Modify or remove SEL-specific access controls </h2>'
  218. call lineout tempfile,'  Note that the input fields are wider then the displayed area. '
  219. call lineout tempfile,'<FORM ACTION="/accescfg" METHOD="POST">'
  220. call lineout tempfile,' <table border=1> <th> Host Nickname  <br> (see below  for a <br>listing of <A HREF="#hosts">current hosts</A>) </th>'
  221. call lineout tempfile,' <th> Candidate SEL  <br> (set to blank to  <br> delete the entry)</th>'
  222. call lineout tempfile,'  <th> Resource privileges </th>'
  223. call lineout tempfile,' <th nowrap> Permissions list....</th> '
  224. call lineout tempfile,'  <th nowrap>Realm, <br> Failure File, & Adv_options File</th> <tr>'
  225.  
  226. nhidden=0 ; mm=0 ; nrealms=0
  227. do mm0=iat to lins.0
  228.     alin=strip(translate(lins.mm0,' ','1a000d0a'x))
  229.     mm=mm+1
  230.  
  231. /* non comment */
  232.     select
  233.       when  abbrev(alin,';')=1 | alin=' ' then do /* comment */
  234.          nhidden=nhidden+1
  235.          alin=sref_replacestrg(alin,'"','"','ALL')
  236.          hiddens.nhidden='<INPUT TYPE="HIDDEN" name="COMMENT.'||mm||'"  value="'||alin||'" >'
  237.          iterate
  238.        end
  239.        when abbrev(alin,'!REALM') then do       /* realm definition */
  240.           parse var alin foo1 realmname accprivs
  241.           nrealms=nrealms+1
  242.           realmvs.therealmname.nrealms=realmname
  243.           realmvs.theaccprivs.nrealms=accprivs
  244.           realmvs.themm.nrealms=mm
  245.           iterate
  246.        end
  247.        when pos('// ',alin)>0 then do   /* host specific entry */
  248.              parse var alin hostname '//' candurl accprivs ',' permlist ',' realm ',' fail_file ',' adv_opts
  249.        end
  250.        otherwise do                     /* generic entry */
  251.              hostname='  '
  252.              parse var alin  candurl accprivs ',' permlist ',' realm ',' fail_file ',' adv_opts
  253.        end
  254.      end  /* Do */
  255.  
  256.      call lineout tempfile,'<td> <EM>Host nickname:</EM> <br> <INPUT TYPE="text" NAME="hostname.'||mm||'"'
  257.      call lineout tempfile,'value="'hostname'" SIZE=8 MAXLENGTH=95> </td> '
  258.      call lineout tempfile,'<td> <EM>Candidate SEL:</EM> <br> <INPUT TYPE="text" NAME="candurl.'||mm||'"'
  259.      call lineout tempfile,'value="'candurl'" SIZE=20 MAXLENGTH=95> </td> '
  260.      call lineout tempfile,'<td> <EM>Resource privileges:</EM> <br> <INPUT TYPE="text" NAME="accprivs.'||mm||'"'
  261.      call lineout tempfile,'value="'accprivs'" SIZE=40 MAXLENGTH=95> </td> '
  262.  
  263.      cacheok=0  ;      NO_SSI=0  ;     NO_SSP=0 ;no_code=0
  264.      ADELETE=0 ;     APUT=0
  265.      NO_VIRTUAL=0 ;     NO_ALIAS=0  ;     NO_POSTFILTER=0
  266.      no_htaccess=0
  267.  
  268.      IF wordpos('CACHE',upper(permlist))>0 then            CACHEOK=1
  269.      if wordpos('NO_SSI',upper(permlist))>0 then            NO_SSI=1
  270.      if wordpos('NO_SSP',upper(permlist))>0 then            NO_SSP=1
  271.      if wordpos('NO_CODE',upper(permlist))>0 then            NO_CODE=1
  272.      if wordpos('DELETE',upper(permlist))>0 then            ADELETE=1
  273.      if wordpos('APUT',upper(permlist))>0 then              APUT=1
  274.      if wordpos('NO_HTACCESS',upper(permlist))>0 then         NO_htaccess=1
  275.      if wordpos('NO_VIRTUAL',upper(permlist))>0 then         NO_VIRTUAL=1
  276.      if wordpos('NO_ALIAS',upper(permlist))>0 then          NO_ALIAS=1
  277.      if wordpos('NO_POSTFILTER',upper(permlist))>0 then      NO_POSTFILTER=1
  278.  
  279. /*say mm cacheok no_ssi no_code no_ssp adelete aput no_virtual no_alias no_postfilter no_htaccess */
  280.  
  281.     call lineout tempfile,' <td>'
  282.     a=MAKECHECK('Cache?','CACHE',MM,CACHEOK)
  283.     call lineout tempfile,' <br>'
  284.     a=makecheck('No SSI? ', 'NO_SSI',mm,no_ssi)
  285.     call lineout tempfile,' <br>'
  286.     a=makecheck('No SSP ', 'NO_SSP',mm,no_ssp)
  287.     call lineout tempfile,' <br>'
  288.     a=makecheck('No CODE ', 'NO_CODE',mm,no_code)
  289.     call lineout tempfile,' <br>'
  290.     a=makecheck('DELETE?   ', 'DELETE',mm,adelete)
  291.     call lineout tempfile,' <br>'
  292.     a=makecheck('PUT? ', 'PUT',mm,aput)
  293.     call lineout tempfile,' <br> '
  294.     a=makecheck('No HTACCESS?  ', 'NO_HTACCESS',mm,no_htaccess)
  295.     call lineout tempfile,' <br>'
  296.     a=makecheck('No Virtual?  ', 'NO_VIRTUAL',mm,no_virtual)
  297.     call lineout tempfile,' <br>' 
  298.     a=makecheck('No Alias? ', 'NO_ALIAS',mm,no_alias)
  299.     call lineout tempfile,' <br>'
  300.     a=makecheck('No Postfilter? ', 'NO_POSTFILTER',mm,no_postfilter)
  301.     call lineout tempfile,' </td>'
  302.  
  303.      realm=strip(realm); fail_file=strip(fail_file) ;adv_opts=strip(adv_opts)
  304.      call lineout tempfile,'<td> <em>Realm: </em><br> <INPUT TYPE="text" NAME="realm.'||mm||'"'
  305.      call lineout tempfile,'value="'realm'" SIZE=8 MAXLENGTH=95>   '
  306.      call lineout tempfile,'<br> <em>Failure File: </em><br> <INPUT TYPE="text" NAME="fail_file.'||mm||'"'
  307.      call lineout tempfile,'value="'fail_file'" SIZE=8 MAXLENGTH=95> <br> '
  308.      call lineout tempfile,'<br> <em>Adv_opts File: </em><br> <INPUT TYPE="text" NAME="adv_opts.'||mm||'"'
  309.      call lineout tempfile,'value="'adv_opts'" SIZE=8 MAXLENGTH=35> <br>'
  310.  
  311.      call lineout tempfile,' </td> '
  312.  
  313.      if mm0<lins.0 then do
  314.            call lineout tempfile,'<tr>' ; call lineout tempfile,' '
  315.      end
  316. end
  317. call lineout tempfile,' </table>' ; call lineout tempfile,' '
  318.  
  319. if nrealms>0 then do
  320.   call lineout tempfile,' '; call lineout tempfile,'<p><h2> Modify/delete Realms </h2>'
  321.   call lineout tempfile,' <table border=1> '
  322.   call lineout tempfile,' <th> Realm name <br> (set to blank to   delete <br> the entry)</th>'
  323.   call lineout tempfile,'  <th> Realm-specific resource privileges list </th> <tr>'
  324.   do jh=1 to nrealms
  325.      call lineout tempfile,'<td> <EM>Realm name:</EM> <br> <INPUT TYPE="text" NAME="realmname.'||realmvs.themm.jh||'"'
  326.      call lineout tempfile,'value="'realmvs.therealmname.jh'" SIZE=8 MAXLENGTH=95> </td> '
  327.      call lineout tempfile,'<td> <EM>Resource privileges:</EM> <br> <INPUT TYPE="text" NAME="accprivs.'||realmvs.themm.jh||'"'
  328.      call lineout tempfile,'value="'realmvs.theaccprivs.jh'" SIZE=40 MAXLENGTH=95> </td> '
  329.      if jh<nrealms then do
  330.        call lineout tempfile,'<tr>' ; call lineout tempfile,' '
  331.      end
  332.  end /* do jh */
  333.  call lineout tempfile,'</table>' ; call lineout tempfile,' '
  334. end
  335.  
  336. /* --- allow user to enter a few new names */
  337. call lineout tempfile,' </table>  <hr width=40%> <h2> Add new SEL-specific access controls </h2> '
  338. mm0=mm
  339. call lineout tempfile,' <table border=1> <th> Host Nickname  </th>'
  340. call lineout tempfile,' <th> Candidate SEL  </th>'
  341. call lineout tempfile,'  <th> Resource privileges </th>'
  342. call lineout tempfile,' <th nowrap>Permissions list .....</th> '
  343. call lineout tempfile,'  <th nowrap>Realm  <br> Failure File <br> & Adv_opts</th> <tr>'
  344.  
  345. do mm=mm0+1 to mm0+3
  346.      call lineout tempfile,'<td> <EM>Host nickname:</EM> <br> <INPUT TYPE="text" NAME="hostname.'||mm||'"'
  347.      call lineout tempfile,'value=" " SIZE=8 MAXLENGTH=95> </td> '
  348.      call lineout tempfile,'<td> <EM>Candidate SEL:</EM> <br> <INPUT TYPE="text" NAME="candurl.'||mm||'"'
  349.      call lineout tempfile,'value=" " SIZE=20 MAXLENGTH=95> </td> '
  350.      call lineout tempfile,'<td> <EM>Resource privileges:</EM> <br> <INPUT TYPE="text" NAME="'accprivs.||mm||'"'
  351.      call lineout tempfile,'value=" " SIZE=40 MAXLENGTH=95> </td> '
  352.     call lineout tempfile,' <td>'
  353.     a=MAKECHECK('Cache?','CACHE',MM,0)
  354.     call lineout tempfile,' <br>'
  355.     a=makecheck('No SSI?  ', 'NO_SSI',mm,0)
  356.     call lineout tempfile,' <br>'
  357.     a=makecheck('No SSP? ', 'NO_SSP',mm,0)
  358.     call lineout tempfile,' <br>'
  359.     a=makecheck('No CODE? ', 'NO_CODE',mm,0)
  360.     call lineout tempfile,' <br>'
  361.     a=makecheck('DELETE?  ', 'DELETE',mm,0)
  362.     call lineout tempfile,' <br>'
  363.     a=makecheck('PUT? ', 'PUT',mm,0)
  364.     call lineout tempfile,' <br>'
  365.      a=makecheck('No HTACCESS?  ', 'NO_HTACCESS',mm,0)
  366.      call lineout tempfile,' <br>'
  367.     a=makecheck('No Virtual?  ', 'NO_VIRTUAL',mm,0)
  368.     call lineout tempfile,' <br>' 
  369.     a=makecheck('No Alias? ', 'NO_ALIAS',mm,0)
  370.     call lineout tempfile,' <br>'
  371.     a=makecheck('No Postfilter? ', 'NO_POSTFILTER',mm,0)
  372.     call lineout tempfile,' </td>'
  373.  
  374.      call lineout tempfile,'<td> <em>Realm: </em><br> <INPUT TYPE="text" NAME="realm.'||mm||'"'
  375.      call lineout tempfile,'value=" " SIZE=8 MAXLENGTH=95> <br>'
  376.  
  377.      call lineout tempfile,'<em>Failure File: </em><br> <INPUT TYPE="text" NAME="fail_file.'||mm||'"'
  378.      call lineout tempfile,'value=" " SIZE=8 MAXLENGTH=95>'
  379.  
  380.      call lineout tempfile,'<em>Adv_opts File: </em><br> <INPUT TYPE="text" NAME="adv_opts.'||mm||'"'
  381.      call lineout tempfile,'value=" " SIZE=8 MAXLENGTH=95>'
  382.  
  383.      call lineout tempfile,' </td>'
  384.  
  385.      if mm<mm0+3 then call lineout tempfile,' <tr> '
  386. end
  387. call lineout tempfile,'</table> <p>'
  388.  
  389. call lineout tempfile,' <h3> Define a new realm </h3> '
  390. mm0=mm0+4
  391. call lineout tempfile,' <u><EM>Realm name:</EM></u>  <INPUT TYPE="text" NAME="realmname.'||mm0||'"'
  392. call lineout tempfile,'value=" " SIZE=8 MAXLENGTH=95>  <br>  '
  393. call lineout tempfile,' <u><EM>Realm-specific resource privileges:</EM></u>  '
  394. call lineout tempfile,' <INPUT TYPE="text" NAME="accprivs.'||mm0||'"'
  395. call lineout tempfile,'value=" " SIZE=40 MAXLENGTH=95>  '
  396.  
  397.  
  398.  
  399. /* ----- add comments information */
  400.  
  401. do jj=1 to nhidden
  402.    call lineout tempfile,hiddens.jj
  403. end /* do */
  404. call lineout tempfile,' <input type="hidden" name="entries" value="'||mm0||'"> <p> '
  405. call lineout tempfile,' <p><input type="submit"> <input type="reset"> </form> '
  406.  
  407.  
  408. call lineout tempfile,' <hr> <h3> <A NAME="notes">Notes</A> </h3> <ul>'
  409. call lineout tempfile,' <li> SEL-specific privileges are stored in: 'accessfile
  410.  
  411. call lineout tempfile,'<li> There are two types of <b>resource privileges </b>:'
  412. call lineout tempfile,'<dl><dt>ONE_OF (the default type).'
  413. call lineout tempfile,'<dd> The client must have "one of" the  ONE_OF privileges.'
  414. call lineout tempfile,'<dt> MUST_HAVE (start with the & character)'
  415. call lineout tempfile,'<dd> The client "must have" <b>all</b> the MUST_HAVE privileges.'
  416. call lineout tempfile,'</dl>'
  417. call lineout tempfile,' Note: if only one privilege is specified, these two types are equivalent.<p>'
  418. call lineout tempfile,' <LI>There are two special ONE_OF privileges: <menu> <li> <STRONG>*</STRONG> :  <em>any privilege will do</em> '
  419. call lineout tempfile,' <LI> <STRONG>NO</STRONG> : No access allowed (SUPERUSERS and INHOUSE user only!) </menu>'
  420. call lineout tempfile,' <li> Do you want to view a  more complete description of '
  421. call lineout tempfile,' <a href="/accescfg?TODO=SHOW_HEADER"> SEL-specific access controls </a>?'
  422. call lineout tempfile,' <li> To add more entries, just rerun this several times <br> or edit ' accessfile
  423. call lineout tempfile,' <li> <em>Comments are NOT displayed </em>  <li> Case is ignored '
  424. call lineout tempfile,' <li> Use a<strong>* </strong> in the <em>candidate SEL </em> as a wildcard character</em>'
  425. call lineout tempfile,'<pre> <em>Discussion of match precedence and wildcarding</em>:'
  426. call lineout tempfile,'   If a <em>request selector </em> can match several <em>candidate SELs</em>...'
  427. call lineout tempfile,'     1) Exact matches take precedence'
  428. call lineout tempfile,'     2) The  <em>wildcard matching candidate SEL </em> with the "longest portion before the *"'
  429. call lineout tempfile,'        is used.'
  430. call lineout tempfile,'     Thus, if the <em> request selector is </em> FOOD/FRUIT/ORANGES.HTM'
  431. call lineout tempfile,'     then the  following would match (with diminishing precedence, '
  432. call lineout tempfile,'     the first being chosen before last):'
  433. call lineout tempfile,'               FOOD/FRUIT/ORANGES.HTM  (the exact match)'
  434. call lineout tempfile,'               FOOD/FRUIT/*'
  435. call lineout tempfile,'               FOOD/*'
  436. call lineout tempfile,' </pre><li> Definitions of the permissions:'
  437. call show_permissions
  438.  
  439. call lineout tempfile, ' <li> Entries with no <strong>host nickname</strong> will apply to all requests'
  440. call lineout tempfile,' <li> If specified (and if <var>ACCESS_FAIL_FILE</var>  < > 0): the <em>failure file</em> is sent '
  441. call lineout tempfile,'   if the client does not have access privileges.'
  442. call lineout tempfile,' <li> The ADV_OPTS file (the <u>advanced options file</u>) should be relative to the GoServe working directory "'
  443. call lineout tempfile,'</ul> <br>'
  444.  
  445. call lineout tempfile,' <h3> A list of the<A NAME="hosts"> current hosts</A> </h3>  <blockquote> '
  446.  
  447. ii=value(enmadd||'HOSTS.0',,'os2environment')
  448. if ii>0 then do
  449. call lineout tempfile,' <table> <th> IP address </th> <th> Host Nickname </th> <th> Data Directory </th> <tr> '
  450. do ll=1 to ii
  451.    wow=value(enmadd||'HOSTS.'||ll,,'os2environment')
  452.    parse var wow ip ',' hn ',' hdir
  453.    call lineout tempfile,' <td> ' ip  '</td> <td> ' hn ' </td> <td> ' hdir '</td> <tr> '
  454. end /* do */
  455. call lineout tempfile,' </table> </blockquote>'
  456. end
  457. else do
  458.   call lineout tempfile,' No HOSTS have been defined   </blockquote>'
  459. end
  460. call lineout tempfile,' <p> <A HREF="#top">Return to the top of this form.</A>'
  461. call lineout tempfile,'</body></html>'
  462. call lineout tempfile
  463.  
  464. foo=sref_expire_response(0.05,dosdir(tempfile))
  465. 'file erase  type text/html name  ' tempfile
  466. return ' done '
  467.  
  468.  
  469.  
  470. /* jump here to recrod changes */
  471. dochange:
  472. parse upper var list foo 'ENTRIES=' nentries '&' .
  473. do ii1=1 to nentries
  474.    fillme.ii1.0=0
  475. end /* do */
  476.  
  477. do until list=""
  478.    parse var list aa '&' list
  479.    parse upper var aa avar '.' aind '=' aval
  480.    aval=packur(aval)
  481.    if abbrev(avar,'ENTRIES=')=1 then iterate
  482.    wow=fillme.aind.0+1
  483.    fillme.aind.0=wow
  484.    fillme.aind.wow.var=avar ; fillme.aind.wow.val=aval
  485.    select
  486.       when avar="COMMENT" then do
  487.           fillme.aind.type='COMMENT'
  488.           parse  var aa foo '=' aval
  489.           fillme.aind.wow.val=packur(aval)
  490.       end
  491.       when avar="CANDURL" then fillme.aind.type='URL'
  492.       when avar="REALMNAME" then fillme.aind.type='REALM'
  493.       
  494.       otherwise nop
  495.    end
  496. end /* do */
  497.  
  498. accessfile=value(enmadd||'ACCESS_FILE',,'os2environment')
  499. aa=fileread(accessfile,'lins',,'E')
  500. foo=do_extends(1)
  501.  
  502. /* pull "header comments" */
  503. iat=0
  504. do until iat >= lins.0
  505.    iat=iat+1
  506.    if  abbrev(strip(lins.iat),';')  then do
  507.        newlines.iat=lins.iat
  508.    end  /* Do */
  509.    else do
  510.         leave
  511.    end
  512. end /* do -- iat is the first non header comment line  */
  513. iat=iat-1
  514.  
  515. do uu=1 to nentries
  516.    select
  517.       when fillme.uu.type='COMMENT' then do
  518.           iat=iat+1
  519.           newlines.iat=fillme.uu.1.val
  520.       end
  521.       when fillme.uu.type='REALM'  then do
  522.           isname=' ' ; ispriv=' ' ;
  523.           do uu2=1 to fillme.uu.0
  524.              chk1=fillme.uu.uu2.var
  525.              if chk1='REALMNAME' then
  526.                 isname=fillme.uu.uu2.val
  527.              if chk1='ACCPRIVS' then
  528.                 ispriv=fillme.uu.uu2.val
  529.           end
  530.           if isname<>' ' then do
  531.               iat=iat+1
  532.               newlines.iat='!REALM '||isname||' '||ispriv
  533.           end
  534.       end
  535.  
  536.       when fillme.uu.type='URL' then do
  537.           candurl=' ' ; permlist=' ' ; ishost=' ' ; isrealm=' ' ; ispriv=' '
  538.           isfailfile=' '; isadv_opts=' '
  539.           do uu2=1 to fillme.uu.0
  540.              chk1=fillme.uu.uu2.var
  541.              vvv=fillme.uu.uu2.val
  542.              select
  543.                 when chk1='CANDURL' then candurl=vvv
  544.                 when chk1='ACCPRIVS' then ispriv=vvv
  545.                 when chk1='REALM' then isrealm=vvv
  546.                 when chk1='FAIL_FILE' then isfailfile=vvv
  547.                 when chk1='HOSTNAME' then ishost=vvv
  548.                 when chk1="ADV_OPTS" then isadv_opts=vvv
  549.                 otherwise  permlist=permlist' ' chk1
  550.              end
  551.           end
  552.           if candurl<>' ' then do
  553.               iat=iat+1
  554.               newlines.iat=''
  555.               if ishost<>' ' then
  556.                   newlines.iat=ishost||'// '
  557.               newlines.iat=newlines.iat||candurl' 'ispriv ' , ' permlist ' , ' isrealm ' , ' isfailfile ',' isadv_opts
  558.           end
  559.       end
  560.       otherwise do
  561.             nop
  562.       end  /* Do */
  563.  
  564.   end                   /* select over type */
  565. end                     /* do over entries */
  566.  
  567. /* save to access_file.. but rename access_file first */
  568. foo=lastpos('.',accessfile)
  569. if foo=0 then
  570.    acf1=accessfile||'.'
  571. else
  572.    acf1=left(accessfile,foo)
  573. do hi=1 to 999
  574.    try1=acf1||hi
  575.    if stream(acf1||hi,'c','query exists')='' then leave
  576. end /* do */
  577. foo=dosrename(accessfile,try1)
  578. newlines.0=iat
  579. foo=filewrite(accessfile,newlines,'R')
  580.  
  581.  
  582. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  583. call lineout tempfile, "<html><head><titLE> SRE-Filter: Changed SEL-specific access controls </title>"
  584.  call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  585.  
  586. call lineout tempfile,' <h2> SEL-specific access controls have been changed </h2>'
  587. call lineout tempfile,' The SEL-specific access controls have been saved to: ' accessfile
  588. call lineout tempfile,' <p> The old version of 'accessfile' has been moved to ' try1
  589. call lineout tempfile,' </body> </html> '
  590. call lineout tempfile
  591.  
  592. foo=value('SREF_REDO',1,'os2environment')
  593.  
  594. foo=sref_expire_response(0.05,dosdir(tempfile))
  595. 'FILE ERASE TYPE text/html NAME' tempfile
  596. return 'done change '
  597.  
  598.  
  599. MAKECHECK:PROCEDURE expose tempfile
  600.   PARSE ARG message, ANAME, MM ,ISIT
  601.   FOO=' <INPUT TYPE="CHECKBOX" NAME="'||ANAME||'.'||MM||'"'
  602.   if isit=1 then
  603.       foo=foo||' VALUE=1 checked> '||message
  604.   else
  605.       foo=foo||'VALUE=1 >'||message
  606.   foo=foo
  607.   call lineout tempfile,foo
  608.   return 1
  609.  
  610. /************/
  611. /* Redo ulist, by treating lines starting with , as continuation lines */
  612. do_extends:procedure expose lins.
  613.  
  614. if lins.0=0 then return
  615. isnew=1
  616. tmps.1=lins.1
  617. do mm=2 to lins.0
  618.    ali=strip(lins.mm)
  619.    if abbrev(ali,',')=0 then do
  620.         isnew=isnew+1
  621.         tmps.isnew=lins.mm
  622.     end
  623.     else do
  624.         tmps.isnew=tmps.isnew||substr(ali,2)
  625.     end
  626. end
  627. do mm=1 to isnew
  628.     lins.mm=tmps.mm
  629. end
  630. lins.0=isnew
  631. return 0
  632.  
  633.  
  634. /* display permissions definitions */
  635. show_permissions:procedure expose tempfile
  636. call lineout tempfile,' <pre>'
  637. call lineout tempfile,'          NO_SSI : NO_SSI means "no server side include allowed for this '
  638. call lineout tempfile,'                   selector (SEL) (or a "path" of selectors, if a * appears).  '
  639. call lineout tempfile,'          NO_SSP : NO_SSP means "no server side processing allowed for this selector".'
  640. call lineout tempfile,'                    (this is rarely used)'
  641. call lineout tempfile,'          NO_CODE: NO_CODE means "do not process SELECT or INTERPRET CODE '
  642. call lineout tempfile,'                   ssi keyphrases". It is a subset of NO_SSP (and is ignored if'
  643. call lineout tempfile,'                   a NO_SSP is present).'
  644. call lineout tempfile,'          CACHE:   If present, then ALWAYS cache this selector (given GoServes'
  645. call lineout tempfile,'                    caching is turned on).'
  646. call lineout tempfile,'                   Typically, if logon controls or access controls are in place,'
  647. call lineout tempfile,'                   then no caching is permittted.  Use of CACHE allows one'
  648. call lineout tempfile,'                   to override this general rule for certain files'
  649. call lineout tempfile,'                   (such as sets of commonly used .GIF files).'
  650. call lineout tempfile,'             PUT : Allow PUT method requests to "copy information to" this selector.'
  651. call lineout tempfile,'           DELETE: Allow DELETE method request to "delete" this selector.'
  652. call lineout tempfile,'      NO_HTACCESS: HTACCESS files will not be used for this selector'
  653. call lineout tempfile,'         NO_ALIAS: Aliasing will NOT be done on this selector'
  654. call lineout tempfile,'       NO_VIRTUAL: Virtual directory lookup will NOT be done on this selector'
  655. call lineout tempfile,'                   NOTE: server side includes and server side processing'
  656. call lineout tempfile,'                        (including CGI-BIN scripts) ignore this directive.'
  657. call lineout tempfile,'                        Thus, NO_VIRTUAL should NOT be used as a security'
  658. call lineout tempfile,'                        tool.'
  659. call lineout tempfile,'     NO_POSTFILTER: Post-filter processing and file recording will NOT'
  660. call lineout tempfile,'                         be done on this selector </pre>'
  661. return 0
  662.  
  663.